<?php
/**
 * 卡券活动组件
 */
class GetCouponWidget extends Widget{
	public function render($data){
		$moduleId = $data['module_id'];
		$accountId = $data['account_id'];
		$userId = $data['user_id'];

		import('@.Service.Coupon.GetCouponService');
		$getCouponService = new GetCouponService();
		$ret = $getCouponService->ifCanGet($accountId,$userId,$moduleId > 0 ? $moduleId : 0);
		if($ret['status'] == 'S'){
			$getData = base64_encode(json_encode(array('act_id' => $ret['data'],'account_id' => $accountId,'user_id' => $userId)));
			$show = 1;
			$url = '/coupon/coupon/index/data/'.$getData;
		}else{
			$show = 0;
			$url = '';
		}

		$data = array(
			'show' => $show,
			'url' => $url,
		);
		$content = $this->renderFile('getcoupon',$data);
		return $content;
	}
}